#include "TYController.h"

#include "GameMenuScene.h"
#include "GameMethodSelectScene.h"
#include "TYSounder.h"
#include "GameMethodPlayScene.h"

#define TRANSITION_DURATION (0.8f)


void RunScene(CCScene* s)
{
	if (!s) return;

	CCScene* runingScene = CCDirector::sharedDirector ()->getRunningScene ();

	if (runingScene)
	{
		CCTransitionScene* replaceScene;
		switch(s->getTag())
		{
		case MAINMENU:

			if ( runingScene->getTag () == METHODSELECT )
			{
				//TYSounder::shareSounder()->playBackground();
				replaceScene =  CCTransitionPageTurn::transitionWithDuration(TRANSITION_DURATION, s, true);
			}

			break;
		case METHODSELECT:
			if ( runingScene->getTag () == MAINMENU )
			{
				//TYSounder::shareSounder()->pauseBackground();
				replaceScene =  CCTransitionPageTurn::transitionWithDuration(TRANSITION_DURATION, s, false);
			}

			break;
		case METHODPLAY1:
			replaceScene =  CCTransitionPageTurn::transitionWithDuration(TRANSITION_DURATION, s, false);
			break;
		}
		if (replaceScene)
		{
			CCDirector::sharedDirector ()->replaceScene (replaceScene);
		}
	} 
	else
	{
		if (s->getTag() == MAINMENU)
		{
			TYSounder::shareSounder()->playBackground();
		}
		CCDirector::sharedDirector ()->runWithScene (s);
	}
}

TYController::TYController(void)
{
}

TYController::~TYController(void)
{
}

void TYController::ShowMainMenuScene ()
{
	GameMenuScene* scene = GameMenuScene::node ();
	scene->setTag (MAINMENU);
	RunScene(scene);
}

void TYController::ShowMethodSelectScene ()
{
	GameMethodSelectScene* scene = GameMethodSelectScene::node ();
	scene->setTag (METHODSELECT);
	RunScene(scene);
}


void TYController::ShowSettingScene ()
{

}


void TYController::ShowUserGuideScene ()
{

}


void TYController::ShowGamePointScene ()
{

}

void TYController::ShowMethodPlayScene()
{
	GameMethodPlayScene* scene = GameMethodPlayScene::node();
	scene->setTag (METHODPLAY1);
	RunScene(scene);
}
